﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:v="clr-namespace:ShredTheLog.Views;assembly=ShredTheLog.Views"
    xmlns:vm="clr-namespace:ShredTheLog.ViewModels;assembly=ShredTheLog.ViewModels"
    xmlns:cnv="clr-namespace:ShredTheLog.Converters;assembly=ShredTheLog.Converters"
    xmlns:c="clr-namespace:ShredTheLog.Controls;assembly=ShredTheLog.Controls"
    >

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="OdigoRadar.xaml"/>
    </ResourceDictionary.MergedDictionaries>
    
    <DataTemplate DataType="{x:Type vm:TextChatViewModel}">
        <Grid x:Name="panel">
            <RadioButton x:Name="roomsRadioButton" IsChecked="True" Content="Rooms" VerticalAlignment="Top" HorizontalAlignment="Left"/>
            <RadioButton x:Name="usersRadioButton" Content="Users" VerticalAlignment="Top" HorizontalAlignment="Right"/>
            
            <ItemsControl x:Name="radar" Style="{StaticResource RadarStyle}"/>
        </Grid>


        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding IsLoading}" Value="true">
                <Setter TargetName="panel" Property="Cursor" Value="Wait"/>
            </DataTrigger>
            <Trigger SourceName="roomsRadioButton" Property="IsChecked" Value="True">
                <Setter TargetName="radar" Property="ItemsSource" Value="{Binding JoinPublicChatRoomCommands}"/>
                <Setter TargetName="radar" Property="ItemTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <DataTemplate.Resources>
                                <Style TargetType="{x:Type ToolTip}" BasedOn="{StaticResource RadarToolTipStyle}"/>
                            </DataTemplate.Resources>
                            <Image Source="{Binding Value.Image}" Width="25" Height="17" Margin="2" Stretch="Uniform">
                                <Image.ToolTip>
                                    <StackPanel Background="Black">
                                        <Image Grid.Row="0" Source="{Binding Value.Image}" Stretch="Uniform" Width="25" Height="17"/>
                                        <TextBlock Grid.Row="1" Text="{Binding Value.Name}" HorizontalAlignment="Center" Margin="2, 0, 2, 0"/>
                                    </StackPanel>
                                </Image.ToolTip>
                                <Image.ContextMenu>
                                    <ContextMenu>
                                        <MenuItem Command="{Binding Value}" Header="{c:LocalizedString s_OpenRoom}"/>
                                    </ContextMenu>
                                </Image.ContextMenu>
                            </Image>
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger SourceName="usersRadioButton" Property="IsChecked" Value="True">
                <Setter TargetName="radar" Property="ItemsSource" Value="{Binding Users}"/>
                <Setter TargetName="radar" Property="ItemTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <ContentControl Style="{StaticResource User_RadarItemStyle}">
                                <ContentControl.ContextMenu>
                                    <ContextMenu c:Extensions.Items="{Binding Converter={x:Static vm:UserMenuItemsConverter.Default}}" DataContext="{Binding RelativeSource={RelativeSource Mode=Self}, Path=PlacementTarget.DataContext}"/>
                                </ContentControl.ContextMenu>
                            </ContentControl>
                        </DataTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </DataTemplate.Triggers>
    </DataTemplate>
</ResourceDictionary>